import javax.swing.*;
import java.util.Scanner;
public class class_74 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double score = sc.nextDouble();
        int month = sc.nextInt();
        String ret = sc.next();
        if (month >= 5 && month <= 10) {
            double m = fun(score, ret,0.9,0.85);
            System.out.println(m);
        } else if (month >= 11 && month <= 12 || month >= 1 && month <= 4) {
            double m = fun(score, ret,0.7,0.65);
            System.out.println(m);
        }
    }
        public static double fun ( double score, String ret,double a, double b) {
            if (ret.equals("头等舱"))
                score *= a;
            else
                score *= b;
            return score;
        }
    }
